Conditions | 1 |
Paths | 2 |
Total Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | var fs = require('fs'); |
||
4 | var walkSync = function (dir, filelist) { |
||
5 | var files = fs.readdirSync(dir); |
||
6 | filelist = filelist || []; |
||
7 | files.forEach(function (file) { |
||
8 | if (fs.statSync(dir + file).isDirectory()) { |
||
9 | filelist = walkSync(dir + file + '/', filelist); |
||
10 | } |
||
11 | else { |
||
12 | filelist.push(dir + file); |
||
13 | } |
||
14 | }); |
||
15 | return filelist; |
||
16 | }; |
||
17 | |||
40 | } |
When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically: